package com.esri.core.tasks.na;

import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.internal.util.d;
import com.esri.core.internal.util.e;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class RouteDirection {
    private String compressedGeometry;
    private long eta;
    private double length;
    private RouteManeuverType maneuver;
    private String text;
    private double time;
    private transient Geometry geometry = null;
    private List<DirectionsString> directionsStrings = new ArrayList();
    private List<DirectionsEvent> directionsEvents = new ArrayList();

    RouteDirection() {
    }

    public double getLength() {
        return this.length;
    }

    public double getMinutes() {
        return this.time;
    }

    public List<DirectionsString> getDirectionsStrings() {
        return this.directionsStrings;
    }

    public List<DirectionsEvent> getDirectionsEvents() {
        return this.directionsEvents;
    }

    public String getText() {
        return this.text;
    }

    public Date getEta() {
        return new Date(this.eta);
    }

    public RouteManeuverType getManeuver() {
        return this.maneuver;
    }

    public Geometry getGeometry() {
        if (this.geometry == null) {
            this.geometry = e.a(this.compressedGeometry);
        }
        return this.geometry;
    }

    public static RouteDirection fromJson(JsonParser jsonParser) throws Exception {
        if (d.c(jsonParser)) {
            RouteDirection routeDirection = new RouteDirection();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if ("attributes".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                            String currentName2 = jsonParser.getCurrentName();
                            jsonParser.nextToken();
                            if ("length".equals(currentName2)) {
                                routeDirection.length = jsonParser.getDoubleValue();
                            } else if ("time".equals(currentName2)) {
                                routeDirection.time = jsonParser.getDoubleValue();
                            } else if ("text".equals(currentName2)) {
                                routeDirection.text = jsonParser.getText();
                            } else if ("ETA".equals(currentName2)) {
                                routeDirection.eta = jsonParser.getLongValue();
                            } else if ("maneuverType".equals(currentName2)) {
                                routeDirection.maneuver = RouteManeuverType.fromString(jsonParser.getText());
                            }
                        }
                    }
                } else if ("compressedGeometry".equals(currentName)) {
                    routeDirection.compressedGeometry = jsonParser.getText();
                } else if ("strings".equals(currentName)) {
                    routeDirection.directionsStrings = new ArrayList();
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                                String str = null;
                                String str2 = null;
                                while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                                    String currentName3 = jsonParser.getCurrentName();
                                    jsonParser.nextToken();
                                    if ("string".equals(currentName3)) {
                                        str2 = jsonParser.getText();
                                    } else if ("stringType".equals(currentName3)) {
                                        str = jsonParser.getText();
                                    }
                                }
                                if (str != null && str.trim().length() != 0 && str2 != null && str2.trim().length() != 0) {
                                    routeDirection.directionsStrings.add(new DirectionsString(DirectionsStringType.fromString(str), str2));
                                }
                            }
                        }
                    }
                } else {
                    jsonParser.skipChildren();
                }
            }
            return routeDirection;
        }
        return null;
    }

    public int hashCode() {
        String str = this.compressedGeometry;
        int hashCode = ((str == null ? 0 : str.hashCode()) + 31) * 31;
        List<DirectionsString> list = this.directionsStrings;
        int hashCode2 = list == null ? 0 : list.hashCode();
        long j = this.eta;
        long doubleToLongBits = Double.doubleToLongBits(this.length);
        int i = (((((hashCode + hashCode2) * 31) + ((int) (j ^ (j >>> 32)))) * 31) + ((int) (doubleToLongBits ^ (doubleToLongBits >>> 32)))) * 31;
        RouteManeuverType routeManeuverType = this.maneuver;
        int hashCode3 = (i + (routeManeuverType == null ? 0 : routeManeuverType.hashCode())) * 31;
        String str2 = this.text;
        int hashCode4 = str2 != null ? str2.hashCode() : 0;
        long doubleToLongBits2 = Double.doubleToLongBits(this.time);
        return ((hashCode3 + hashCode4) * 31) + ((int) ((doubleToLongBits2 >>> 32) ^ doubleToLongBits2));
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            RouteDirection routeDirection = (RouteDirection) obj;
            String str = this.compressedGeometry;
            if (str == null) {
                if (routeDirection.compressedGeometry != null) {
                    return false;
                }
            } else if (!str.equals(routeDirection.compressedGeometry)) {
                return false;
            }
            List<DirectionsString> list = this.directionsStrings;
            if (list == null) {
                if (routeDirection.directionsStrings != null) {
                    return false;
                }
            } else if (!list.equals(routeDirection.directionsStrings)) {
                return false;
            }
            if (this.eta == routeDirection.eta && Double.doubleToLongBits(this.length) == Double.doubleToLongBits(routeDirection.length)) {
                RouteManeuverType routeManeuverType = this.maneuver;
                if (routeManeuverType == null) {
                    if (routeDirection.maneuver != null) {
                        return false;
                    }
                } else if (!routeManeuverType.equals(routeDirection.maneuver)) {
                    return false;
                }
                String str2 = this.text;
                if (str2 == null) {
                    if (routeDirection.text != null) {
                        return false;
                    }
                } else if (!str2.equals(routeDirection.text)) {
                    return false;
                }
                return Double.doubleToLongBits(this.time) == Double.doubleToLongBits(routeDirection.time);
            }
            return false;
        }
        return false;
    }

    public String toString() {
        return "RoutingDirection [length=" + this.length + ", time=" + this.time + ", text=" + this.text + ", eta=" + this.eta + ", maneuver=" + this.maneuver + ", compressedGeometry=" + this.compressedGeometry + ", directionsStrings=" + this.directionsStrings + "]";
    }

    void setEta(long j) {
        this.eta = j;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void setTime(double d) {
        this.time = d;
    }

    void setText(String str) {
        this.text = str;
    }

    void setLength(double d) {
        this.length = d;
    }

    void addDirectionsString(String str, String str2) {
        this.directionsStrings.add(new DirectionsString(DirectionsStringType.valueOf(str), str2));
    }

    void setGeometry(byte[] bArr) {
        this.geometry = GeometryEngine.geometryFromEsriShape(bArr, Geometry.Type.UNKNOWN);
    }

    void setRoutingManeuver(String str) {
        this.maneuver = RouteManeuverType.valueOf(str);
    }

    void addDirectionsEvent(DirectionsEvent directionsEvent) {
        this.directionsEvents.add(directionsEvent);
    }
}
